const fs=require("fs");
        module.exports = class extends baseController {
            constructor() {
                super();
                this.Items=[];
                this.router.all('/setUserLocation', this.setUserLocation.bind(this));
                this.router.get("/longConn",this.longConn.bind(this));
                return this.router;
            }
        
            static init() {
                return new this();
            }

            /**
             * 获取用户位置信息
             * @param {*} req 
             * @param {*} res 
             */
            setUserLocation(req,res){
                let model={
                    lat:req.body.lat || 0,
                    lng:req.body.lng || 0,
                    userId:req.body.userId || 0,
                    time:req.body.time || 0
                }
                this.Items.push(model);
                log.debug(model);
                let ret = this.Success(1,model);
                res.json(ret);
            }

            //长连接测试
            async longConn(req,res,next){
        
                try{
                    let self=this;
                    var getItems=async (cb)=>{
                        log.debug(11);
                        if(self.Items.length>0){
                            res.send(self.Items);
                            self.Items.splice(0,self.Items.length-1);
                        }else{
                            setTimeout(()=>{
                                 getItems();
                            },1000)
                            
                        }
                    }
                   await getItems();
                    
                }catch(err){
        
                }
            }
        };
        